/**
 * 
 */
package com.jm.web.form;

import com.jm.utils.AttributeBuilder;
import com.jm.web.form.support.FormItem;
import com.jm.web.tags.support.BaseTag;
import com.jm.web.tags.support.DataSourceTag;

/**
 * @author yanjie
 *
 * 2011/10/6 下午2:13:28
 */
public class Option extends FormItem{
	public final static String TAG_ITEMNAME = "option";
	
	protected String strValue = "" ;
	

	public String getValue() {
		return strValue;
	}


	public void setValue(String strValue) {
		this.strValue = strValue;
	}
	
	@Override
	public void OnSetProperty(String strName, String strValue) {
		if("value".equalsIgnoreCase(strName)){
			this.setValue(strValue);
		}
		
		super.OnSetProperty(strName, strValue);
	}


	/**
	 * @param tag
	 */
	public Option() {}
	
	
	@Override
	public void init() {
		super.init();
		this.setNodeName(TAG_ITEMNAME);
	}
	
	@Override
	public void FillAttributeBuilder(AttributeBuilder attributesBuilder) {
		
		if(this.GetExtValue("bind", true))
		{
			if(this.getBaseTag() instanceof DataSourceTag){
				DataSourceTag dsTag = (DataSourceTag)this.getBaseTag();
				dsTag.FillFiledItemValue(this);
			}
			
			//bind 参数用来控制此控件是否由平台来绑定数据
			if(this.GetExtValue("selected", false)){
				attributesBuilder.Set("selected", "true");
			}
		}
		
		attributesBuilder.Set("value", this.getValue(),true);
		super.FillAttributeBuilder(attributesBuilder);
	}
}
